package com.xjl.javacore.code.ioexample.tcp;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 创建服务端
 * @author xiaojinlu1990@163.com
 * @date 2020/1/21 9:45
 */
public class TcpService {
    public static void main(String[] args) throws Exception {
        ServerSocket serverSocket = new ServerSocket(12321);

        while (true){
            Socket accept = serverSocket.accept();

            InputStream inputStream = accept.getInputStream();
            byte[] bytes = new byte[1024];
            int read = inputStream.read(bytes);
            System.out.println(new String(bytes,0,read));
        }

    }
}
